#include "registerresponsemessage.h"

RegisterResponseMessage::RegisterResponseMessage(const Status& status, const Reason& reason, const UserId& userId)
{
    m_messageType = MessageType::RegisterResponse;
    m_status = status;
    m_reason = reason;
    m_userId = userId;
}

RegisterResponseMessage::RegisterResponseMessage(const QJsonObject& jsonObj)
{
    m_messageType = static_cast<MessageType>(jsonObj[JsonKey::TYPE].toInt());
    m_status = jsonObj[JsonKey::STATUS].toString();
    m_reason = jsonObj[JsonKey::REASON].toString();
    m_userId = jsonObj[JsonKey::USER_ID].toString();
}

QJsonObject RegisterResponseMessage::PackJsonData() const
{
    QJsonObject jsonObj;
    jsonObj[JsonKey::TYPE] = static_cast<int>(m_messageType);
    jsonObj[JsonKey::STATUS] = m_status;
    jsonObj[JsonKey::REASON] = m_reason;
    jsonObj[JsonKey::USER_ID] = m_userId;
    return jsonObj;
}

Status RegisterResponseMessage::getStatus() const
{
    return m_status;
}

Reason RegisterResponseMessage::getReason() const
{
    return m_reason;
}

UserId RegisterResponseMessage::getUserId() const
{
    return m_userId;
}
